import 'package:flutter/material.dart';

void showSimpleConfirmDialog(BuildContext context, String title, String message, Function() onConfirm) {
  showDialog(
    context: context,
    builder: (BuildContext context) {
      return AlertDialog(
        title: Text(title),
        content: Text(message),
        actions: [
          TextButton(
            onPressed: () {
              Navigator.of(context).pop();
            },
            child: const Text('Cancel'),
          ),
          TextButton(
            onPressed: () {
              onConfirm();
              Navigator.of(context).pop();
            },
            child: const Text('Confirm'),
          ),
        ],
      );
    },
  );
}

void showTermOfUseAndPrivacyPolicyDialog(BuildContext context, Function(bool) onAgree) {
  showDialog(
    context: context,
    builder: (BuildContext context) {
      return Dialog(
        child: Container(
          padding: const EdgeInsets.only(left: 24, right: 24, top: 24, bottom: 12),
          decoration: const BoxDecoration(
            color: Color(0xFFFFFFFF),
            borderRadius: BorderRadius.only(
              topLeft: Radius.circular(12),
              topRight: Radius.circular(12),
              bottomLeft: Radius.circular(12),
              bottomRight: Radius.circular(12),
            ),
          ),
          child: Column(
            mainAxisSize: MainAxisSize.min,
            children: [
              Image.asset(
                'assets/images/bt_logo_small.png',
                width: 52,
                height: 52,
              ),
              const SizedBox(height: 12),
              const Text(
                'BrewTunes',
                style: TextStyle(fontSize: 16, color: Color(0xFF404040), fontWeight: FontWeight.bold),
              ),
              const SizedBox(height: 15),
              const Text(
                'By using our App you agree with our  Term of Use  and Privacy Policy.',
                style: TextStyle(fontSize: 14, color: Color(0xFF404040)),
              ),
              const SizedBox(height: 22),
              Container(
                width: 198,
                height: 40,
                decoration: BoxDecoration(
                  color: const Color(0xFF4DB4FF),
                  borderRadius: BorderRadius.circular(58), // 圆角半径
                ),
                child: TextButton(
                  onPressed: () {
                    onAgree(true);
                    Navigator.of(context).pop();
                  },
                  child: const Text('Agree and Continue',
                      textAlign: TextAlign.center,
                      style: TextStyle(fontSize: 14, color: Color(0xFFFFFFFF), fontWeight: FontWeight.bold)),
                ),
              ),
              const SizedBox(height: 5),
              TextButton(
                onPressed: () {
                  onAgree(false);
                  Navigator.of(context).pop();
                },
                child: const Text('Cancel',
                    textAlign: TextAlign.center,
                    style: TextStyle(fontSize: 14, color: Color(0x4d000000), fontWeight: FontWeight.normal)),
              ),
            ],
          ),
        ),
      );
    },
  );
}
